package com.blog.cloud.auth.oauth.properties;

import com.blog.cloud.auth.oauth.config.AuthConfig;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

import java.net.Proxy;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "justauth")
public class AuthProperties {
    private boolean enabled;
    private Map<String, AuthConfig> type = new HashMap<>();
    private AuthProperties.JustAuthHttpConfig httpConfig;

    @NestedConfigurationProperty
    private AuthCacheProperties cache = new AuthCacheProperties();

    @Setter
    @Getter
    public static class JustAuthHttpConfig {
        private int timeout;
        private Map<String, AuthProperties.JustAuthProxyConfig> proxy;

        public JustAuthHttpConfig() {
        }

    }

    @Setter
    @Getter
    public static class JustAuthProxyConfig {
        private String type;
        private String hostname;
        private int port;

        public JustAuthProxyConfig() {
            this.type = Proxy.Type.HTTP.name();
        }

    }
}
